package cn.tsinghua.comsmacitccntsinghua.httpservice;
import android.net.Uri;
import android.util.Log;

import java.util.Map;

import cn.tsinghua.comsmacitccntsinghua.bean.EquipmentStatusBean;
import cn.tsinghua.comsmacitccntsinghua.bean.EventReportBean;
import cn.tsinghua.comsmacitccntsinghua.bean.GPSBean;
import cn.tsinghua.comsmacitccntsinghua.bean.UserBean;
import cn.tsinghua.comsmacitccntsinghua.bean.WarnReport;
import cn.tsinghua.comsmacitccntsinghua.bean.WeightBean;
import cn.tsinghua.comsmacitccntsinghua.tsinterface.IHttpHelper;
import cn.tsinghua.comsmacitccntsinghua.tsinterface.INpResponse;
import cn.tsinghua.comsmacitccntsinghua.tsinterface.IStringResponse;

/**
 * 与服务器交互的全部接口  RESTAPI
 */
public class API {
    private static final String TAG = "API";
    private  static IHttpHelper httpHelper;
    private  static String serverUrl = "http://47.116.65.116:8092";
    private static String myServerUrl = "http://47.98.99.133:8181";

    /**
     * API组件初始化，不可static直接赋值，防止GlobalInfo未初始化造成null
     */
    public static void init(){
        httpHelper=ServiceFactory.httpHelper;
    }
    /**
     * 1、设备信息接口（设备自主触发，APP启动时）
     * http://58.221.137.62:9601/getOrganizationInfo
     */
    public static void getOrganizationInfo(Map map, IStringResponse response){
        httpHelper.post(serverUrl+"/getOrganizationInfo",map,response);
        Log.d(TAG,"------------getOrganizationInfo-------------");
//        httpHelper.get(myServerUrl+"/info/getOrganizationInfo",map,response);
    }

    /**
     * 3、扫码身份验证接口
     * http://58.221.137.62:9601/scanCodeCertification
     */
    public static void scanCodeCertification(Map map, IStringResponse response){
        httpHelper.post(serverUrl+"/scanCodeCertification",map,response);
        Log.d(TAG,"------------scanCodeCertification-------------");
    }

    /**
     * 4、投递数据接口
     */
    public static void retrieveRes(WeightBean weightBean, IStringResponse response){
        httpHelper.post(serverUrl+"/retrieveRes",weightBean,response);
        Log.d(TAG,"------------retrieveRes-------------");
    }
    /**
     * 6、设备状态数据接口（设备自主触发，默认半小时一次）
     */
    public static void equipmentStatus(EquipmentStatusBean equipmentStatusBean, IStringResponse response){
        httpHelper.post(serverUrl+"/equipmentStatus",equipmentStatusBean,response);
        Log.d(TAG,"------------equipmentStatus-------------");
    }
    /**
     * 7、事件上报接口（设备自主触发）
     */
    public static void eventReport(EventReportBean eventReportBean, IStringResponse response){
        httpHelper.post(serverUrl+"/eventReport",eventReportBean,response);
        Log.d(TAG,"------------eventReport-------------");
    }
    /**
     * 8、故障上报接口
     */
    public static void warnReport(WarnReport warnReport, IStringResponse response){
        httpHelper.post(serverUrl+"/warnReport",warnReport,response);
        Log.d(TAG,"------------warnReport-------------");

    }

    /**
     * 9. 管理员登录接口
     */
    public static void getManagerInfo(UserBean userBean, IStringResponse response){
        httpHelper.post(serverUrl+"/warnReport",userBean,response);
        Log.d(TAG,"------------getManagerInfo-------------");
    }

    /**
     * 10、上传GPS接口
     */
    public static void GPSInfo(GPSBean gpsBean,IStringResponse response){
        httpHelper.post(serverUrl+"/receiveDeviceLngAndLat",gpsBean,response);
        Log.d(TAG,"------------GPSInfo-------------");
    }

}
